
<?php 
if($_REQUEST['_a']=="d")
{
	$id = $_REQUEST['_d'];
	mysql_query("delete from scholarships where id='$id'");
	echo "<script>window.location='index.php?tc=scholarship&page=$page&_s=2'</script>";
}
?>
<form name="nnf" method="post" action="#">
<table border="0" width="100%" align="center">
<tr>
	<td width="46%" align="left"><span style="color:#1B78B7; font-size:14px; font-weight:bold">
    Scholarship</span>&nbsp; 
	
	</td>
	<td width="40%" align="right" class="font12">
  <a href="index.php?tc=add_scholarship" class="font12">Add New</a>  
   
	<td width="14%" align="right"><select name="_st" onchange="window.location='index.php?tc=scholarship&page=<?php echo $_REQUEST['page'];?>&_st='+this.value">
	  <option value="" <?php if($_REQUEST['_st']=="") echo "selected";?>><--Sort--></option>
	  <option value="2" <?php if($_REQUEST['_st']==2) echo "selected";?>>All</option>
	  <option value="1" <?php if($_REQUEST['_st']==1) echo "selected";?>>Approved Ads</option>
	  <option value="3" <?php if($_REQUEST['_st']==3) echo "selected";?>>Pending Ads</option>
	  </select></td>
</tr>
<tr>
	<td background="images/topline.gif" colspan="3" height="11"></td>
</tr>    
</table>
</form>
	<?php
if($_REQUEST['_s'] == 2)
{ ?>
	<table align="center" border="0">
	<tr>
    	<td align="center"><div class="sucmsg"><img src="images/information.png" align="absmiddle" />&nbsp;Deleted Successfully</div></td>
    </tr>    
    </table>
<?php } ?>
<?php
if($_REQUEST['_s'] == 1)
{ ?>
	<table align="center" border="0">
	<tr>
    	<td align="center"><div class="sucmsg"><img src="images/information.png" align="absmiddle" />&nbsp;Updated Successfully</div></td>
    </tr>    
    </table>
<?php } ?>
<table width="100%" align="center" border="0" class="list">
<thead>
<tr class="headings">
	<td align="center" width="30">#</td>
    <td align="center" width="300">University </td>
	<td align="center" width="250">Course name</td>
    <td align="center" width="250">Scholarship </td>
	<td align="center" width="250">Url </td>
     <td align="center" width="50">Status</td>
    <td align="center">Action</td>
</tr>
</thead>
<?php
include('includes/function.php');
$self="index.php?tc=scholarship&_st=".$_REQUEST['_st'];
$rowsPerPage = 20;
$pageNum = 1;
if(isset($_GET['page']))
{
	$pageNum = $_GET['page'];
}
if($_GET['page']=="")
{
	$pageNum = 1;
}

/*<!--counting the offset-->*/
$offset = ($pageNum - 1) * $rowsPerPage;
$st = $_REQUEST['_st'];

if($st == "" || $st == 2)
{
	$res = mysql_query("select id from scholarships");
	
	$query = mysql_query("select s.id id,`scholarship_name`, `details_description`, `duration`, `extra_details`, `general_info`, `eligible_instruction`, s.active_status,u.university_name,u.url,c.course_name from scholarships s left join university u on u.id=s.university_id left join  course c on c.id=s.`course_id` limit $offset , $rowsPerPage") or die(mysql_error());
}
else
{
	if($st == 3) $st=0;
	$res = mysql_query("select id from scholarships where active_status='$st'");
	$query = mysql_query("select s.id id,s.scholarship_name, s.details_description, s.duration, s.extra_details, s.general_info, s.eligible_instruction,s.active_status,u.university_name,u.url,c.course_name from scholarships s left join university u on u.id=s.university_id left join  course c on c.id=s.`course_id` where s.active_status='$st'  order by id desc limit $offset , $rowsPerPage");
}
$i = 1;
while($q = mysql_fetch_array($query))
{ 
	if($q["active_status"] == 1) $status = "Approved";
	else $status = "Pending";
	?>
    <tr class="font12">
    <td align="center"><?php echo $i+$offset;?></td>
    <td align="left" ><?php echo strip_tags(stripcslashes($q["university_name"]));?></td>
    <td align="left" ><?php echo strip_tags(stripcslashes($q["course_name"]));?></td>
    <td align="left" ><?php echo strip_tags(stripcslashes($q["scholarship_name"]));?></td>
     <td align="left" ><?php echo $q["url"];?></td>  
           
       
         <td align="center"><?php echo $status;?></td>
        <td align="center"><a href="index.php?tc=add_scholarship&_d=<?php echo $q['id'];?>&page=<?php echo $pageNum;?>&m=edit" class="font12">Edit</a> | 
        	<a href="index.php?tc=scholarship&_d=<?php echo $q['id'];?>&_a=d&page=<?php echo $pageNum;?>" onclick="return confirm('Are you sure want to delete?')" class="font12">Delete</a>
        </td>
   	</tr>     
<?php 
	$i++;
}
?>
<?php 
if(mysql_num_rows($res) <= $rowsPerPage){	}
else { ?>
<tr>
    <td colspan="7" align="center"  bgcolor="#E3ECF3">
        <?php echo $paginglink=getPagingLink($res, $rowsPerPage,$pageNum,$self); ?>	
    </td>
</tr>
<?php } ?>
</table>    